<script setup>
import GoodsItem from '../Home/components/GoodsItem.vue';
import { useBanner } from './composables/useBanner';
import { useCategory } from './composables/useCategory';
defineOptions({
    name:"indexItem"
})
// 分类逻辑
const { allList,getTwoObj } = useCategory()
// 轮播图逻辑
const { BannerList } = useBanner()
</script>
<template>

  <!-- 面包屑 -->
    <div class="mbx">
         <div class="content">
              <el-breadcrumb separator="/">
              <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
              <el-breadcrumb-item>{{ getTwoObj.name }}</el-breadcrumb-item>
             </el-breadcrumb>
         </div>
    </div>


    <!-- 轮播图 -->
    <div class="block text-center" m="t-4">
          <el-carousel height="450px" :interval = 500 arrow="hover">
            <el-carousel-item v-for="item in BannerList" :key="item.id">
              <img :src="item.imgUrl" alt="null" width="100%" height="100%">
            </el-carousel-item>
          </el-carousel>
  </div>
  
  <!-- 全部分类 -->
  <div class="all">
    <h1>--全部分类--</h1>
      <ul>
        <li v-for="item in allList" :key="item.id">
          <router-link :to="`/category/sub/${item.id}`">
            <img :src="item.picture" alt="" width="100%" height="150px">
            <p class="name" style="text-align: center;">{{ item.name }}</p>
          </router-link>
        </li>
      </ul>
  </div>
  <div class="body">
        <div class="lay" v-for="item in allList" :key="item.id">
          <h1>{{ item.name }}</h1>
            <ul>
               <li v-for="item in item.goods" :key="item.id" >
                 <GoodsItem :item="item"></GoodsItem>
              </li>
            </ul>
        </div>
  </div>
</template>
<style scoped>
  .mbx{
    display: flex;
    align-items: center;
    width: 100%;
    height: 20px;
  }
  .content{
    width: 1200px;
    margin: 0 auto;
  }
  .block{
    width: 1200px;
    margin: 0 auto;
  }
  .all{
    width: 1200px;
    margin: 50px auto;
    background-color: #fff;
  }
   .all h1{
    text-align: center;
    font-weight: 400;
    color: #999;
    margin-bottom: 20px;
   }
  .all ul{
    display: flex;
    justify-content: space-evenly;
    width: 100%;
  }
  .all ul li{
    width: 150px;
    height: 180px;
  }
  .body{
    width: 1200px;
    margin: 0 auto 30px;
  }
  .body .lay{
    margin-bottom: 30px;
    width: 1200px;
    height: 332px;
    background: #fff;
  }
  .body .lay h1{
    font-family: "SimSun", sans-serif;
    color: #999;
    font-weight: 400;
  }
  .body .lay ul {
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 100%;
  }
  .body .lay li{
    text-align: center;
    width: 220px;
    height: 292px;
  }
</style>